<!doctype html> 
<html> 
<head> 
  <meta charset="utf-8"/>
  <title>后台管理系统</title>
  <meta name="author" content="DeathGhost" />
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <!--[if lt IE 9]>
  <script src="js/html5.js"></script>
  <![endif]-->
<script src="js/jquery.js"></script>
<script src="js/jquery.mCustomScrollbar.concat.min.js"></script>
<script>
  (function($){
    $(window).load(function(){
      
      $("a[rel='load-content']").click(function(e){
        e.preventDefault();
        var url=$(this).attr("href");
        $.get(url,function(data){
          $(".content .mCSB_container").append(data); //load new content inside .mCSB_container
          //scroll-to appended content 
          $(".content").mCustomScrollbar("scrollTo","h2:last");
        });
      });
      
      $(".content").delegate("a[href='top']","click",function(e){
        e.preventDefault();
        $(".content").mCustomScrollbar("scrollTo",$(this).attr("href"));
      });
      
    });
  })(jQuery);
</script>

</head>
<body>
  <section class="rt_wrap content mCustomScrollbar">
 <div class="rt_content">
     



     <section>
      <h2><strong style="color:grey;"></strong></h2>
      <div class="page_title">
       <h2 class="fl">职位列表</h2>
       <a class="fr top_rt_btn" href="positionAdd" target='mainFrame'>添加职位</a>
      </div>
      <table class="table">
       <tr>
        <th>职位编号</th>
        <th>职位名称</th>
        <th>职位描述</th>
        <th>职位状态</th>
        <th>职位热度</th>
        <th>操作</th>
       </tr>
       @foreach($list as $v)

       <tr id="dels{{$v->position_id}}">
        <td>{{$v->position_id}}</td>
        <td>
          @if($v->leval ==0)

          @elseif($v->leval ==1)
            |-
          @else
            &nbsp;&nbsp;|-
          @endif
          <span id='old{{$v->position_id}}' onclick="update('{{$v->position_id}}')">{{$v->position_name}}</span>
          <input type="text" id="new{{$v->position_id}}" value="{{$v->position_name}}" style="display:none;" onblur="doUp('{{$v->position_id}}')"/>
        </td>
        <td>{{$v->position_id}}</td>
        <td id="stu{{$v->position_id}}">
        @if($v->position_stu == 0)
          <span onclick="check_stu(1,{{$v->position_id}})">启用</span>
        @else
          <span onclick="check_stu(0,{{$v->position_id}})">禁用</span>
        @endif
        </td>
        <td>{{$v->position_hot}}</td>
        <td style="text-align:center;">
         <span onclick="dels({{$v->position_id}})">删除</span>
        </td>
       </tr>
       @endforeach
       
      </table>
      <aside class="paging">
       <a>第一页</a>
       <a>1</a>
       <a>2</a>
       <a>3</a>
       <a>…</a>
       <a>1004</a>
       <a>最后一页</a>
      </aside>
     </section>
     

 </div>
</section>
</body>
<script type="text/javascript">
function update(id)
{
    $('#old'+id).hide();
    $('#new'+id).show();
}
function doUp(id)
{
    var val=$('#new'+id).val();
    var url='positionUpdate';
    var data={'id':id,'val':val,'do':'save','_token':"{{csrf_token()}}",'zd':'position_name'};
    $.post(url,data,function(msg){
      if(msg){
        $('#old'+id).html(val);
        $('#old'+id).show();
        $('#new'+id).hide();
      }
      
    })
}

function check_stu(val,id)
{
    var url='positionUpdate';
    var data={'id':id,'val':val,'do':'save','_token':"{{csrf_token()}}",'zd':'position_stu'};
    $.post(url,data,function(msg){
      if(msg){
         if(val=='1'){
           $('#stu'+id).html('<span onclick="check_stu(0,'+id+')">禁用</span>');
         }else{
           $('#stu'+id).html('<span onclick="check_stu(1,'+id+')">启用</span>');
         }
      }
      
    })
}

function dels(id)
{
    var url='positionUpdate';
    var data={'id':id,'val':'','do':'del','_token':"{{csrf_token()}}",'zd':''};
    $.post(url,data,function(msg){
      if(msg){
        $('#dels'+id).remove();
      }
      
    })
}
</script>
</html>


